package com.inossem.warehousestorage_inossem.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;

import com.inossem.warehousestorage_inossem.R;

/**
 * Created by Administrator on 2017/8/12 0012.
 */

public class StatusTextView extends android.support.v7.widget.AppCompatTextView {

    private int status = 0 ;//0:未处理，1:处理部分，2:处理完,3:新增的

    public StatusTextView(Context context) {
        super(context);
    }

    public StatusTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public StatusTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {


        // 定义画笔2
        Paint paint2 = new Paint();
        // 消除锯齿
        paint2.setAntiAlias(true);
        // 设置画笔的颜色
        paint2.setColor(getResources().getColor(R.color.base_green));
        if(getStatus()==1){
            canvas.drawRect(0, getMeasuredHeight()/2, getMeasuredWidth(), getMeasuredHeight(), paint2);
        }else if(getStatus()==2||getStatus()==3){
            canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), paint2);
        }

        super.onDraw(canvas);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
        this.invalidate();
    }
}
